﻿using IntelligentAgriculture.Contracts.Dto.Output.ManageOutput;
using IntelligentAgriculture.Contracts.Interface.IManagements;
using IntelligentAgriculture.WebAPI.Application.Command.ManageCommand;
using IntelligentAgriculture.WebAPI.Application.CommandHandler.ManageHandler;
using MediatR;
using Microsoft.EntityFrameworkCore.Internal;
using IntelligentAgriculture.Contracts.Dto.Output.RidgepOutPut;
using IntelligentAgriculture.Services.Management;
using IntelligentAgriculture.Contracts.Interface.Iridgepletype;
using IntelligentAgriculture.WebAPI.Application.Command.RidgepCpoamd;
using IntelligentAgriculture.Contracts.Dto.Output.PageOutput;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.RidgepCommandHandler
{
    public class RidgepShowCommandHandler : IRequestHandler<RidgepShowCommand, Results<PagesOutput<RidgepShowOutput>>>
    {
        private readonly IridegpoleService _iregisteredServices;
        private readonly ILogger<ManageCommandHander> _logger;
        public RidgepShowCommandHandler(IridegpoleService iregisteredServices, ILogger<ManageCommandHander> logger)
        {
            _iregisteredServices = iregisteredServices;
            _logger = logger;
        }


        /// <summary>
        /// 提供显示、查询和分页功能。
        /// </summary>
        /// <param name="request">包含显示、查询和分页所需的请求参数</param>
        /// <param name="cancellationToken">用于取消操作的令牌</param>
        /// <returns>返回执行显示、查询和分页操作的结果</returns>
        public async Task<Results<PagesOutput<RidgepShowOutput>>> Handle(RidgepShowCommand request, CancellationToken cancellationToken)
        {
            try
            {
                var list = _iregisteredServices.GetShow(request.Eitag);
                var results = Results<PagesOutput<RidgepShowOutput>>.DataResult(list);

                return results;
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
